<?php

namespace App\Models;

use App\Services\ChargeService;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SmsTemplate extends Model
{
    use HasFactory;
    protected $table = 'sp_sms_template';
    protected $primaryKey = 'id';
    public $timestamps = false;

    //sms_type短信类型 1供应商提醒  2用户提醒
    const SMS_TEMPLATE_SMS_TYPE_SHOPER = 1;//供应商提醒
    const SMS_TEMPLATE_SMS_TYPE_USER = 2;//用户提醒

    const SMS_TEMPLATE_ORDER_PLACE_SEND_SHOP = 1;//下单成功通知商户
    const SMS_TEMPLATE_ORDER_REFUND_SEND_SHOP = 2;//用户申请退款提醒
    const SMS_TEMPLATE_PAID_SEND_USER = 4;//支付成功通知用户
    const SMS_TEMPLATE_ORDER_DELIVERY = 5;//发货成功
    const SMS_TEMPLATE_EXPRESS_SIGN = 6;//订单物流签收
    const SMS_TEMPLATE_GUARANTEE_BALANCE_LESS = 8;//担保合同账户余额不足
    const SMS_TEMPLATE_SMS_BALANCE_LESS = 9;//短信账户余额不足
    const SMS_TEMPLATE_GUARANTEE_AUTO_CHARGE_OPEN = 10;//担保合同自动充值开启
    const SMS_TEMPLATE_SMS_AUTO_CHARGE_OPEN = 11;//短信自动充值开启
    const SMS_TEMPLATE_SMS_CHARGE_SUCCESS = 12;//短信充值成功
    const SMS_TEMPLATE_GUARANTEE_CHARGE_SUCCESS = 13;//担保合同充值成功
    const SMS_TEMPLATE_ORDER_COLLECTION = 14;//订单租金催收提醒
    const SMS_TEMPLATE_GUARANTEE_SIGN = 15;//担保合同签署
    const SMS_TEMPLATE_ORDER_REFUND_SUCCESS = 16;//退款成功
    const SMS_TEMPLATE_SMS_AUTO_CHARGE_FAIL = 17;//短信自动充值失败
    const SMS_TEMPLATE_GUARANTEE_CHARGE_FAIL = 18;//担保合同充值失败
    const SMS_TEMPLATE_OFFLINE_PAY_CODE = 19;//线下支付验证码
    const SMS_TEMPLATE_REPAYMENT_REMINDER = 20;//订单还款提醒
    const SMS_TEMPLATE_WITHHOLD_FAIL = 21;//订单扣款失败提醒
    const SMS_TEMPLATE_ORDER_OVERDUE = 22;//订单逾期提醒
    const SMS_TEMPLATE_ORDER_OVERDUE_BEYOND = 23;//订单逾期超过15天提醒
    const SMS_TEMPLATE_ORDER_AUTH_REMIND = 24;//微信用户未实名认证提醒
    const SMS_TEMPLATE_REPAYMENT_REMINDER_TWO = 25;//订单还款提醒

    const SMS_TEMPLATE_REPAYMENT_ORDER_AUDIT = 27;//提醒用户接听电话


    protected function getSmsContent($template_id){
        $sms_template = $this->where([['id',$template_id],['sms_status',ChargeService::SMS_TEMPLATE_STATUS_OPEN]])->value('clsms_content');
        return $sms_template;
    }

    protected function GetOneSmsTemplate($where)
    {
        $data = $this
            ->where($where)
            ->first();
        $data = $data ? $data->toArray() : [];
        return $data;
    }

    protected function GetSmsTemplate($where)
    {
        $data = $this
            ->where($where)
            ->get();
        $data = $data ? $data->toArray() : [];
        return $data;
    }



}
